var helper = require("../../../util/helper");

module.exports = function (app) {
	return new Handler(app);
};

var Handler = function (app) {
	this.app = app;
};

var pro = Handler.prototype;

pro.enter = function (msg, session, next) {
	var token = helper.genuuid();
	console.log("entryHandler.enter: token is %s.", token);
	session.on("closed", leave.bind(null, this.app));
	next(null, { code: 200, token: token });
};

var leave = function (app, session) {
	console.log("entryHandler.leave: session is %s.", session.uid);
};

pro.exit = function (msg, session, next) {
	session.close();
};